#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>

struct nameless {
	int **data;
	int *data_n;
	int amount;
};

int
merge_seqs(int *s1, const int s1_n, int *s2, const int s2_n, int *sorted)
{
	register int i, j, s;

	s = i = j = 0;
	while (i < s1_n && j < s2_n) {
		if (s1[i] < s2[j])
			sorted[s++] = s1[i++];
		else
			sorted[s++] = s2[j++];
	}
	while (i < s1_n)
		sorted[s++] = s1[i++];
	while (j < s2_n)
		sorted[s++] = s2[j++];

	return 0;
}

int *
gen_seq(int a, int d, int n)
{
	int *ret;
	register int i;

	ret = malloc(n * sizeof *ret);
	ret[0] = a;
	for (i = 1; i < n; i++)
		ret[i] = ret[i - 1] + d;

	return ret;
}

int
main(int argc, char **argv)
{
	int amount, a, d, n;
	int max_n = -1;
	struct nameless s;
	register int i, count;
	int step;
	int *extbuf = NULL;
	int *newbuf = NULL;
	int j;

	scanf("%d", &s.amount);
	s.data = malloc(sizeof *s.data * s.amount);
	s.data_n = calloc((size_t) s.amount, sizeof *s.data_n);
	for (i = 0; i < s.amount; i++) {
		scanf("%d%d%d", &a, &d, &n);
		if (n > max_n)
			max_n = n;
		s.data[i] = gen_seq(a, d, n);
		s.data_n[i] = n;
	}

	for (step = 1; step <= s.amount; step <<= 1) {
		for (i = 0; i + step < s.amount; i += step << 1) {
			/* mess */
			extbuf = malloc((s.data_n[i] + s.data_n[i + step]) * sizeof *extbuf);
			merge_seqs(s.data[i], s.data_n[i], s.data[i + step], s.data_n[i + step], extbuf);
			free(s.data[i]);
			s.data[i] = extbuf;
			s.data_n[i] += s.data_n[i + step];
			s.data_n[i + step] = 0;
		}
	}
	for (i = s.amount - 1; i >= 0; i--) {
		if (s.data_n[i]) {
			for (j = i - 1; j >= 0; j--) {
				if (s.data_n[j]) {
					extbuf = malloc((s.data_n[i] + s.data_n[j]) * sizeof *extbuf);
					merge_seqs(s.data[i], s.data_n[i], s.data[j], s.data_n[j], extbuf);
					free(s.data[j]);
					s.data[j] = extbuf;
					s.data_n[j] += s.data_n[i];
					s.data_n[i] = 0;
				}
			}
		}
	}

	count = 1;
	for (i = 1; i < s.data_n[0]; ++i)
		if (s.data[0][i - 1] != s.data[0][i])
			++count;
	printf("%d\n", count);

	for (i = 0; i < s.amount; i++)
		free(s.data[i]);
	free(s.data);
	free(s.data_n);
	return 0;
}
